// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class AUTHORIZATION_INFO_RSP_E22 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("10 IVC",10)]
  	    [HL7Field(HL7Version.v26, 10, HL7Repeat.False, HL7Required.True,"IVC")]
	    public IVC IVC {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("11 PSG",11)]
  	    [HL7Field(HL7Version.v26, 11, HL7Repeat.False, HL7Required.True,"PSG")]
	    public PSG PSG {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("12 PSL_ITEM_INFO",12)]
  	    [HL7Field(HL7Version.v26, 12, HL7Repeat.True, HL7Required.True,"PSL_ITEM_INFO_RSP_E22")]
	    public PSL_ITEM_INFO_RSP_E22[] PSL_ITEM_INFO {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			IVC = PopSegmentParseAndCheckRequired<IVC>(availableData, options, "IVC");
			PSG = PopSegmentParseAndCheckRequired<PSG>(availableData, options, "PSG");
			PSL_ITEM_INFO = ProcessGroupArray<PSL_ITEM_INFO_RSP_E22>(availableData, options, "PSL_ITEM_INFO");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isIVC = availableData.StartsWith("IVC", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IVC", options.Version) || isIVC) {
				return isIVC;
			}
			bool isPSG = availableData.StartsWith("PSG", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("PSG", options.Version) || isPSG) {
				return isPSG;
			}
			PSL_ITEM_INFO_RSP_E22 testPSL_ITEM_INFO_RSP_E22 = new PSL_ITEM_INFO_RSP_E22();
			bool grpCCPSL_ITEM_INFO_RSP_E22 = (testPSL_ITEM_INFO_RSP_E22.CanConsume(availableData, options));
			if (IsRequired("PSL_ITEM_INFO", options.Version) || grpCCPSL_ITEM_INFO_RSP_E22) {
				return grpCCPSL_ITEM_INFO_RSP_E22;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "AUTHORIZATION_INFO";
			}
        }

        static AUTHORIZATION_INFO_RSP_E22() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(AUTHORIZATION_INFO_RSP_E22));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (IVC != null) {
			string segmentValue = IVC.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (PSG != null) {
			string segmentValue = PSG.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (PSL_ITEM_INFO != null && PSL_ITEM_INFO.Length > 0) {
			for (int i = 0; i < PSL_ITEM_INFO.Length; i++) {
				string segmentValue = PSL_ITEM_INFO[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

